package org.absolutezero.client.view;

import javax.inject.Inject;

import org.absolutezero.client.events.NavigationChangeEvent;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class NavigationMenuView extends Composite {

	private static NavigationMenuUiBinder uiBinder = GWT
			.create(NavigationMenuUiBinder.class);

	interface NavigationMenuUiBinder extends UiBinder<Widget, NavigationMenuView> {
	}
	
	private final EventBus ebus;

	@UiField
	Button btnMyShelves;
	
	@UiField
	Button btnBrowseShelves;
	
	@UiField
	Button btnMatchRecipe;
	
	@UiField
	Button btnBrowseRecipes;
	
	@UiField
	Button btnMyRecipes;
	
	@UiHandler("btnMyShelves")
	public void onMyShelvesClick(ClickEvent e){
		ebus.fireEvent(new NavigationChangeEvent(NavigationChangeEvent.NavigationItemSelected.SHELF_MY));
	}
	
	@UiHandler("btnBrowseShelves")
	public void onBrowseShelvesClick(ClickEvent e){
		ebus.fireEvent(new NavigationChangeEvent(NavigationChangeEvent.NavigationItemSelected.SHELF_BROWSE));
	}
	
	@UiHandler("btnMatchRecipe")
	public void onMatchRecipeClick(ClickEvent e){
		ebus.fireEvent(new NavigationChangeEvent(NavigationChangeEvent.NavigationItemSelected.RECIPE_MATCH));
	}
	
	@UiHandler("btnBrowseRecipes")
	public void onBrowseRecipesClick(ClickEvent e){
		ebus.fireEvent(new NavigationChangeEvent(NavigationChangeEvent.NavigationItemSelected.RECIPE_BROWSE));
	}
	
	@UiHandler("btnMyRecipes")
	public void onMyRecipesClick(ClickEvent e){
		ebus.fireEvent(new NavigationChangeEvent(NavigationChangeEvent.NavigationItemSelected.RECIPE_MY));
	}
	
	
	@Inject
	public NavigationMenuView(EventBus ebus) {
		this.ebus = ebus;
		
		initWidget(uiBinder.createAndBindUi(this));
	}


}
